﻿using System.Web.Http;

namespace WebApi
{
    public class WebApiApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);
        }

        //WebApi跨域请求，在Global中添加代码(测试，本地服务器不行)
        //protected void Application_BeginRequest(object sender, EventArgs e)
        //{
        //    HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
        //    if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
        //    {
        //        HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "*");
        //        HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "*");
        //        HttpContext.Current.Response.End();
        //    }
        //}
    }
}
